home *** CD-ROM | disk | FTP | other *** search
/ C++ für Kids / C++ for kids.iso / SETUP / US / CBUILDER / DATA.Z / LIMITS.H < prev    next >
C/C++ Source or Header  |  1997-02-13  |  37KB  |  1,065 lines

  1. /*  limits.h
  2.  
  3.     Defines implementation specific limits on type values.
  4.  
  5. */
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 8.0
  9.  *
  10.  *      Copyright (c) 1987, 1997 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. #if !defined(__USING_STD_NAMES__)
  16.  
  17. #ifndef __LIMITS_H
  18. #define __LIMITS_H
  19.  
  20. #if !defined(___DEFS_H)
  21. #include <_defs.h>
  22. #endif
  23.  
  24. #define CHAR_BIT        8               /* number of bits in a char */
  25. #define MB_LEN_MAX      2               /* max. # bytes in multibyte char */
  26.  
  27. #define SCHAR_MIN     (-128)            /* minimum signed   char value */
  28. #define SCHAR_MAX       127             /* maximum signed   char value */
  29. #define UCHAR_MAX       255             /* maximum unsigned char value */
  30.  
  31. #if ('\x80' < 0)
  32. #define CHAR_MIN        SCHAR_MIN       /* minimum char value */
  33. #define CHAR_MAX        SCHAR_MAX       /* maximum char value */
  34. #else
  35. #define CHAR_MIN        0
  36. #define CHAR_MAX        UCHAR_MAX
  37. #endif
  38.  
  39. #define SHRT_MIN      (-32767-1)        /* minimum signed   short value */
  40. #define SHRT_MAX        32767           /* maximum signed   short value */
  41. #define USHRT_MAX       65535U          /* maximum unsigned short value */
  42.  
  43. #define LONG_MIN      (-2147483647L-1)  /* minimum signed   long value */
  44. #define LONG_MAX        2147483647L     /* maximum signed   long value */
  45. #define ULONG_MAX       4294967295UL    /* maximum unsigned long value */
  46.  
  47. #if defined(__FLAT__)
  48. #define _I64_MIN      (-9223372036854775807i64-1) /* minimum signed   __int64 value */
  49. #define _I64_MAX        9223372036854775807i64    /* maximum signed   __int64 value */
  50. #define _UI64_MAX       18446744073709551615ui64  /* maximum unsigned __int64 value */
  51. #endif
  52.  
  53. #if !defined(__FLAT__)
  54. #define INT_MIN         SHRT_MIN        /* minimum signed   int value */
  55. #define INT_MAX         SHRT_MAX        /* maximum signed   int value */
  56. #define UINT_MAX        USHRT_MAX       /* maximum unsigned int value */
  57. #else
  58. #define INT_MIN         LONG_MIN
  59. #define INT_MAX         LONG_MAX
  60. #define UINT_MAX        ULONG_MAX
  61. #endif
  62.  
  63.  
  64. #if defined(__FLAT__) && defined(_POSIX_)
  65.  
  66. #define _POSIX_ARG_MAX          4096
  67. #define _POSIX_CHILD_MAX        6
  68. #define _POSIX_LINK_MAX         8
  69. #define _POSIX_MAX_CANON        255
  70. #define _POSIX_MAX_INPUT        255
  71. #define _POSIX_NAME_MAX         14
  72. #define _POSIX_NGROUPS_MAX      0
  73. #define _POSIX_OPEN_MAX         16
  74. #define _POSIX_PATH_MAX         255
  75. #define _POSIX_PIPE_BUF         512
  76. #define _POSIX_SSIZE_MAX        32767
  77. #define _POSIX_STREAM_MAX       8
  78. #define _POSIX_TZNAME_MAX       3
  79.  
  80. #define ARG_MAX                 (16384 - 256)   /* 16k-(heap overhead+safety) */
  81. #define CHILD_MAX               32
  82. #define LINK_MAX                _POSIX_LINK_MAX
  83. #define MAX_CANON               _POSIX_MAX_CANON
  84. #define MAX_INPUT               _POSIX_MAX_INPUT
  85. #define NAME_MAX                255
  86. #define NGROUPS_MAX             16
  87. #define OPEN_MAX                32
  88. #define PATH_MAX                512
  89. #define PIPE_BUF                _POSIX_PIPE_BUF
  90. #define SSIZE_MAX               _POSIX_SSIZE_MAX
  91. #define STREAM_MAX              20
  92. #define TZNAME_MAX              10
  93.  
  94. #endif /* POSIX */
  95.  
  96. #endif  /* __LIMITS_H */
  97.  
  98. #else   /* __USING_STD_NAMES__ */
  99.  
  100. #ifndef __STD_LIMITS
  101. #define __STD_LIMITS
  102.  
  103. /***************************************************************************
  104.  *
  105.  * limits - Declarations for the Standard Library limits class
  106.  *
  107.  * $Id: limits,v 1.42 1995/09/29 01:06:31 smithey Exp $
  108.  *
  109.  ***************************************************************************
  110.  *
  111.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  112.  * ALL RIGHTS RESERVED
  113.  *
  114.  * The software and information contained herein are proprietary to, and
  115.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  116.  * intends to preserve as trade secrets such software and information.
  117.  * This software is furnished pursuant to a written license agreement and
  118.  * may be used, copied, transmitted, and stored only in accordance with
  119.  * the terms of such license and with the inclusion of the above copyright
  120.  * notice.  This software and information or any other copies thereof may
  121.  * not be provided or otherwise made available to any other person.
  122.  *
  123.  * Notwithstanding any other lease or license that may pertain to, or
  124.  * accompany the delivery of, this computer software and information, the
  125.  * rights of the Government regarding its use, reproduction and disclosure
  126.  * are as set forth in Section 52.227-19 of the FARS Computer
  127.  * Software-Restricted Rights clause.
  128.  *
  129.  * Use, duplication, or disclosure by the Government is subject to
  130.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  131.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  132.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  133.  * P.O. Box 2328, Corvallis, Oregon 97339.
  134.  *
  135.  * This computer software and information is distributed with "restricted
  136.  * rights."  Use, duplication or disclosure is subject to restrictions as
  137.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  138.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  139.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  140.  * then the "Alternate III" clause applies.
  141.  *
  142.  **************************************************************************/
  143.  
  144. #include <stdcomp.h>
  145. #include <stddefs.h>
  146.  
  147. #ifndef RWSTD_NO_NEW_HEADER
  148. #include <cfloat>
  149. #include <climits>
  150. #else
  151. #include <float.h>
  152. #include <limits.h>
  153. #endif
  154.  
  155. //
  156. // Hack to get around some <math.h>s defining an exception structure.
  157. //
  158. #define exception math_exception
  159.  
  160. #ifndef RWSTD_NO_NEW_HEADER
  161. #include <cmath>
  162. #else
  163. #include <math.h>
  164. #endif
  165.  
  166. //
  167. // Undo the hack.
  168. //
  169. #undef exception
  170.  
  171. //
  172. // WARNING: this is a hack to get around MSVC's complex
  173. //
  174. #ifdef _MSC_VER
  175. #ifdef complex
  176. #undef complex
  177. #endif
  178. #endif
  179.  
  180. #ifndef RWSTD_NO_NAMESPACE
  181. namespace std {
  182. #endif
  183.  
  184. enum float_round_style
  185. {
  186.     round_indeterminable      = -1,
  187.     round_toward_zero         =  0,
  188.     round_to_nearest          =  1,
  189.     round_toward_infinity     =  2,
  190.     round_toward_neg_infinity =  3
  191. };
  192.  
  193. template <class T>
  194. class numeric_limits
  195. {
  196.   public:
  197.  
  198.     static const bool is_specialized;
  199.  
  200.     static inline T min () { return (T) 0; }
  201.     static inline T max () { return (T) 0; }
  202.  
  203.     static const int digits;
  204.     static const int digits10;
  205.  
  206.     static const bool is_signed;
  207.     static const bool is_integer;
  208.     static const bool is_exact;
  209.  
  210.     static const int radix;
  211.     static inline T  epsilon     () { return (T) 0; }
  212.     static inline T  round_error () { return (T) 0; }
  213.  
  214.     static const int min_exponent;
  215.     static const int min_exponent10;
  216.     static const int max_exponent;
  217.     static const int max_exponent10;
  218.  
  219.     static const bool has_infinity;
  220.     static const bool has_quiet_NaN;
  221.     static const bool has_signaling_NaN;
  222.     static const bool has_denorm;
  223.  
  224.     static inline T infinity      () { return (T) 0; }
  225.     static inline T quiet_NaN     () { return (T) 0; }
  226.     static inline T signaling_NaN () { return (T) 0; }
  227.     static inline T denorm_min    () { return min(); }
  228.  
  229.     static const bool is_iec559;
  230.     static const bool is_bounded;
  231.     static const bool is_modulo;
  232.  
  233.     static const bool traps;
  234.     static const bool tinyness_before;
  235.  
  236.     static const float_round_style round_style;
  237. };
  238.  
  239. #ifndef RWSTD_NO_TEMPLATE_SPECIALIZATION
  240. template <class T>
  241. const bool numeric_limits<T>::is_specialized = false;
  242.  
  243. template <class T>
  244. const int numeric_limits<T>::digits = 0;
  245.  
  246. template <class T>
  247. const int numeric_limits<T>::digits10 = 0;
  248.  
  249. template <class T>
  250. const bool numeric_limits<T>::is_signed = false;
  251.  
  252. template <class T>
  253. const bool numeric_limits<T>::is_integer = false;
  254.  
  255. template <class T>
  256. const bool numeric_limits<T>::is_exact = false;
  257.  
  258. template <class T>
  259. const int numeric_limits<T>::radix = 0;
  260.  
  261. template <class T>
  262. const int numeric_limits<T>::min_exponent10 =0;
  263.  
  264. template <class T>
  265. const int numeric_limits<T>::max_exponent1